package com.example.jpademo.Service;

import com.example.jpademo.DAO.PaperDAO;
import com.example.jpademo.Entity.Paper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;

import java.util.List;

@Service
public class PaperService {
    @Autowired
    PaperDAO paperDAO;
    //增（上传论文）
    public void addPaper(Paper paper){
        paperDAO.save(paper);
    }
    //分配审稿人
    //这里先全都分给前三个reviewer
    @Transactional
    public void allocate(Paper paper){
        paper.setReviewerAID(1);
        paper.setReviewerBID(2);
        paper.setReviewerCID(3);
    }
    //查（查看下载论文）
    public List<Paper> getAllPaper(){
        return paperDAO.findAll();
    }
    //删（只有大学能调用）
    public void deletePaper(Integer id){
        paperDAO.deleteById(id);
    }
    //改
    public void updatePaper(Paper paper){
        paperDAO.save(paper);
    }
}
